﻿<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:sys="clr-namespace:System;assembly=mscorlib" 
  xmlns:resx="clr-namespace:iTuner.Properties"
  mc:Ignorable="d"
  xmlns:local="clr-namespace:iTuner"
  x:Class="iTuner.TrackPanel"
  x:ClassModifier="internal"
  d:DesignWidth="220" d:DesignHeight="70">

  <UserControl.Resources>
    <local:RatingConverter x:Key="RatingConverter" />
    <local:SourcesConverter x:Key="SourcesConverter" />

    <Style TargetType="TextBlock">
      <Setter Property="FontSize" Value="12"/>
      <Setter Property="FontFamily" Value="Calibri"/>
    </Style>
    <Style x:Key="InfoLabelStyle" TargetType="TextBlock">
      <Setter Property="FontSize" Value="11"/>
      <Setter Property="FontFamily" Value="Calibri"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="HorizontalAlignment" Value="Right"/>
      <Setter Property="Margin" Value="0,0,3,0"/>
    </Style>
    <Style x:Key="InfoStyle" TargetType="TextBlock">
      <Setter Property="FontSize" Value="11"/>
      <Setter Property="FontFamily" Value="Calibri"/>
      <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
      <Setter Property="ToolTip" Value="{Binding Path=Text, RelativeSource={RelativeSource Self}}" />
    </Style>
  </UserControl.Resources>

  <local:DetailPanel x:Name="Container">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="{Binding ElementName=Container,Path=ActualWidth}" />
      </Grid.ColumnDefinitions>
      <Grid
        x:Name="detailPanel" Background="Transparent" 
        SnapsToDevicePixels="True" Margin="4,0,9,0" Visibility="Hidden">
        <Grid.RowDefinitions>
          <RowDefinition/>
          <RowDefinition/>
          <RowDefinition/>
          <RowDefinition/>
          <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Row="0" Text="{x:Static resx:Resources.TrackPanel_Title}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="1" Text="{x:Static resx:Resources.TrackPanel_Artist}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="2" Text="{x:Static resx:Resources.TrackPanel_Album}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="3" Text="{x:Static resx:Resources.TrackPanel_Year}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="4" Text="{x:Static resx:Resources.TrackPanel_Track}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding CurrentTrack.Title}" Style="{StaticResource InfoStyle}" />
        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding CurrentTrack.Artist}" Style="{StaticResource InfoStyle}"  MouseDown="DoOpenArtistURL" Cursor="Hand" />
        <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CurrentTrack.Album}" Style="{StaticResource InfoStyle}" />
        <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CurrentTrack.Year}" Style="{StaticResource InfoStyle}" />
        <TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding CurrentTrack.TrackNumber}" Style="{StaticResource InfoStyle}" />

        <TextBlock Grid.Row="0" Grid.Column="2" Text="{x:Static resx:Resources.TrackPanel_Length}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="1" Grid.Column="2" Text="{x:Static resx:Resources.TrackPanel_Genre}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="2" Grid.Column="2" Text="{x:Static resx:Resources.TrackPanel_Rating}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="3" Grid.Column="2" Text="{x:Static resx:Resources.TrackPanel_Kind}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="4" Grid.Column="2" Text="{x:Static resx:Resources.TrackPanel_Location}" Style="{StaticResource InfoLabelStyle}" />
        <TextBlock Grid.Row="0" Grid.Column="3" Text="{Binding CurrentTrack.Time}" Style="{StaticResource InfoStyle}" />
        <TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding CurrentTrack.Genre}" Style="{StaticResource InfoStyle}" />
        
        <TextBlock
            Grid.Row="2" Grid.Column="3"
            Text="{Binding CurrentTrack.Rating, Converter={StaticResource RatingConverter}}"
            Style="{StaticResource InfoStyle}" />

        <TextBlock
          Grid.Row="3" Grid.Column="3" Text="{Binding CurrentTrack.Kind}"
          Style="{StaticResource InfoStyle}" />

        <TextBlock
            x:Name="locationBlock" MouseDown="DoOpenLocation"
            Grid.Row="4" Grid.Column="3" Cursor="Hand"
            Text="{Binding CurrentTrack.Location}"
            Style="{StaticResource InfoStyle}" />
      </Grid>

      <Grid
        x:Name="playPanel" Background="Transparent"
        SnapsToDevicePixels="True" Margin="4,0,9,0" Visibility="Visible">
        <Grid.RowDefinitions>
          <RowDefinition/>
          <RowDefinition/>
          <RowDefinition/>
          <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <local:EditBlock
          x:Name="titleBlock"
          Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center"
          FontWeight="Bold" FontSize="11" FontFamily="Segoe UI"
          Text="{Binding CurrentTrack.Title, Mode=TwoWay}"
          ToolTip="{Binding CurrentTrack.Location}"
          TextTrimming="CharacterEllipsis" />

        <local:EditBlock
          x:Name="artistBlock" MouseDown="DoOpenArtistURL" Cursor="Hand"
          Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center"
          Text="{Binding CurrentTrack.Artist, Mode=TwoWay}"
          TextTrimming="CharacterEllipsis" />

        <local:TimeControl
          Grid.Row="2" VerticalAlignment="Center"/>

        <local:EditBlock
          x:Name="albumBlock"
          Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center"
          Text="{Binding CurrentTrack.Album, Mode=TwoWay}"
          ToolTip="{Binding CurrentTrack.Year}"
          TextTrimming="CharacterEllipsis" />
      </Grid>

      <ToggleButton
        x:Name="flipper" ToolTip="{x:Static resx:Resources.TrackPanel_ChangeView}" Focusable="False"
        Style="{StaticResource FlipButtonStyle}" Width="11" Height="11"
        HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,3,7,0"
        Click="ToggleView"  />

      <Image
        x:Name="sourceImage"
        Source="{Binding Converter={StaticResource SourcesConverter}, Path=CurrentSource}"
        ToolTip="{Binding CurrentSource}"
        Width="12" Height="12"
        HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,3,0,0" />

    </Grid>
  </local:DetailPanel>
</UserControl>
